<template lang="pug">
  app-page
    app-data-view(pagination)
      app-table-container
        template(slot="action")
          router-link(to="/template/action?type=create")
            el-button(size="small", type="primary") 自定义模板

        el-table(ref="table", :data="table.data", v-loading="table.loading", height="100%", stripe)
          el-table-column(prop="date", label="日期", width="180")
          el-table-column(prop="name", label="姓名", width="180")
          el-table-column(prop="address", label="地址")
</template>

<script>
import { request } from '@/util/net'
import pageMixin from '@/mixins/page'

function getData(param) {
  console.log(param)
  return request(
    Array.from({ length: param.length || 20 }, (v, k) => ({
      name: '王小虎',
      address: `上海市普陀区金沙江路 151${k} 弄`
    }))
  )
}

export default {
  name: 'TemplateIndex',
  mixins: [
    pageMixin({
      request: getData,
      immediate: false
    })
  ],
  setup() {
    const form = { mechanismId: null }

    return {
      form
    }
  },
  created() {
    this.form.mechanismId = this.currentMechanism.mechanismId
    this.search()
  }
}
</script>
